#include "leftborderform.h"
#include "ui_leftborderform.h"
#include <QPainter>
#include <QStyleOption>

LeftBorderForm::LeftBorderForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LeftBorderForm)
{
    ui->setupUi(this);
    this->setProperty("form","leftType0");
}

LeftBorderForm::~LeftBorderForm()
{
    delete ui;
}

void LeftBorderForm::UpdateShowType(int type)
{
    switch (type) {
    case 0:
        this->setProperty("form","leftType0");
        break;
    case 1:
        this->setProperty("form","leftType1");
        break;
    case 2:
        this->setProperty("form","leftType2");
        break;
    case 3:
        this->setProperty("form","leftType3");
        break;
    default:
        break;
    }
    // 强制样式更新
    this->style()->unpolish(this);
    this->style()->polish(this);
    this->update();
}

void LeftBorderForm::SetLabelIcon(QString strType)
{
    ui->label_icon->setProperty("form",strType);
}

void LeftBorderForm::paintEvent(QPaintEvent *event)
{
    QStyleOption opt;
    opt.init(this);
    QPainter painter(this);
    style()->drawPrimitive(QStyle::PE_Widget,&opt,&painter,this);
    QWidget::paintEvent(event);
}
